<?php
	
	/*** include the mysqli custom library ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR. 'lib' . DIRECTORY_SEPARATOR . 'mysqli_library.php';
 	
	/*** include the model class ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR. 'core' . DIRECTORY_SEPARATOR . 'base_model.php';
 	
 	/*** include the controller class ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR. 'core' . DIRECTORY_SEPARATOR . 'base_controller.php';

 	/*** include the registry class ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'registry.php';

 	/*** include the router class ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR .'core' . DIRECTORY_SEPARATOR. 'router.php';
	
 	/*** include the template class ***/
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'template.php';
 	
 	/*** include helpers */
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'url_helper.php';

 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'form_helper.php';
		 	
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'session_helper.php';

 	/*** include constants */
 	include __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'constants.php';
 	
 	/*** auto load model classes ***/
    function __autoload($class_name) 
    {
    	$filename = strtolower($class_name) . '.php';
    	$file = __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . $filename;

    	if (file_exists($file) == false)
    	{
        	return false;
    	}
  		
    	include ($file);
	}
	
	/*** Start the Session **/
 	session_start(); 
	
 	/*** a new registry object ***/
 	$registry = new Registry();

 	/*** Create mysqli instance ***/
 	$registry->db = new Mysqli_library('127.0.0.1', 'tecnicosya_usr', 'tecnicosya_usr', 'tecnicosya');
 	
	/*** load the router ***/
	$registry->router = new Router($registry);
	
	/*** set the controller path ***/
	$registry->router->setPath(__SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'controllers');
	
	/*** load up the template ***/
	$registry->template = new Template($registry);
	
	/*** load the controller ***/
	$registry->router->loader();
?>
